<?php
namespace User\Controller;
use Think\Controller;

  
 
class GameController extends Controller {
    function __construct(){
        parent::__construct();
		
			if (!CheckLogin()) {
		
			//$this->redirect('Home/Login/index', array() , 0, '未登陆，跳转到登陆界面...');
		}       
    }

	
    public function index(){
			$UserId = session('UserId');
			$default_begin_time = date("Y-m-d",strtotime("-3 Days")); 
			$default_end_time =date("Y-m-d",time());
			$startTime = I('get.start_date',$default_begin_time);		
			$preSevenDays = strtotime("-7 Days");
			
			if(strtotime($startTime)<$preSevenDays){
				$startTime = date("Y-m-d", $preSevenDays); 
			}			
			$endTime = I('get.end_date',$default_end_time);			
			if(strtotime($endTime)>time()){
				$endTime = $default_end_time; 
			}


			$condition['nuserid']=$UserId;
			$condition['dtime'] = array('BETWEEN',array($startTime,date("Y-m-d", strtotime("$endTime+1 days"))));
			$G = M('tbppclog');
			$count =$G->where($condition)
					  ->count();
			$items =15;
			$Page = new \Think\Userpage($count,$items);
					
			$data = $G->field('nrunnum,cjettons,nprizeitem,nprizemoney,nmoney,dtime')
					  ->where($condition)
					  ->order('dtime DESC')
					  ->limit($Page->firstRow.','.$Page->listRows)	
					  ->select();
			$listshow = $Page->show(); 
			$this->assign('list',$listshow);
			$this->assign('data',$data);
			$this->assign('startTime',I('get.start_date',$default_begin_time));			
			$this->assign('endTime',I('get.end_date',$default_end_time));		
		
		$this->display();   	
    }



	

}